Skip to content

Mid-point color is now the middle of the diverging color scale #3086

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

dariyasydykova
Copy link
Contributor

This pull request closes issue #3072.

The issue has been fixed by changing the number of colors generated by brewer_pal from 6 to 7. The mid-point now has a color that matches the mid-point on the color scale. This change was implemented in scale_color_distiller(). The function scale_fill_distiller() also had this issue and was also fixed.

library(ggplot2)

dat <- data.frame(x = -1:1)

ggplot(dat) + geom_point(aes(x = x, y = 1, color = x), size = 12) +
 scale_color_distiller(palette = 'RdBu', direction = 1, limits = c(-1, 1))

ggplot(dat) + geom_raster(aes(x = x, y = 1, fill = x)) +
  scale_fill_distiller(palette = 'RdBu', direction = 1, limits = c(-1, 1))

Created on 2019-01-19 by the reprex package (v0.2.1)

Copy link
Member

@karawoo karawoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good! Could you please rename the test file to test-scale-brewer.R? We generally use kebab case most often for the names of test files (though it is admittedly inconsistent).

@@ -19,6 +19,8 @@
* Default labels are now generated more consistently; e.g., symbols no longer
get backticks, and long expressions are abbreviated with `...`
(@yutannihilation, #2981).

* Diverging brewer color scale now has the correct mid-point color (@dariyasydykova, #3072).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please move this so it is the first bullet in the section?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per discussion with @clauswilke, I leave it where it is.

@dariyasydykova
Copy link
Contributor Author

I changed test file test-scale_brewer.R to test-scale-brewer.R. Thanks!

@karawoo karawoo merged commit 86fed3f into tidyverse:master Jan 19, 2019
@lock
Copy link

lock bot commented Jul 18, 2019

This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/

@lock lock bot locked and limited conversation to collaborators Jul 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants